{include file='common/head'}
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>充值管理</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="{:url('admin/user/chongzhiindex')}" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
            <div class="layui-input-inline">
                <select name="cateid">
                    <option value="">搜索关键词</option>
                    <option value="u_phone">账号</option>
                </select>
            </div>
            <input type="text" name="Key"  placeholder="请输入关键词" autocomplete="off" class="layui-input">
            <input type="submit" name="sub" class="layui-btn" value="开始搜索" lay-submit="" lay-filter="sreach">
        </form>
    </div>
    <table class="layui-table">
        <thead>
        <tr style="text-align: center">
            <th style="text-align: center">NO</th>
            <th style="text-align: center">订单号</th>
            <th style="text-align: center">账号</th>
            <th style="text-align: center">姓名</th>
            <th style="text-align: center">充值金额</th>
            <th style="text-align: center">充值方式</th>
            <th style="text-align: center">充值时间</th>
            <th style="text-align: center">状态</th>
            <th style="text-align: center">备注(前8字)</th>
            {if $Think.session.admin_uid==1}<th style="text-align: center">操作</th>{else/}{/if}
        </tr>
        </thead>
        <tbody>
        {volist name="rs" id="rs"}
        <tr style="text-align: center">
            <td>{$key+1}</td>
            <td>{$rs.c_number}</td>
            <td>{$rs.u_phone}</td>
            <td>{$rs.u_name}</td>     
            <td>{$rs.c_money}</td>
            <td>{$rs.z_type}</td>
            <td>{$rs.c_createtime}</td>
            <td class="td-status"><span>{if $rs.c_state==1}<span class="layui-btn layui-btn-sm layui-btn-danger">等待充值</span>{elseif $rs.c_state==3}<span class="layui-btn layui-btn-sm">充值完成</span>{else/}<span class="layui-btn layui-btn-sm layui-btn-normal">已退回</span>{/if}</span></td>
            <td>{$rs['c_descs']|mb_substr=0,8,'utf-8'}</td>
            {if $Think.session.admin_uid==1}
            <td class="td-manage">
                <span>
                {if $rs.c_state==2}
                {$rs['c_reason']|mb_substr=0,8,'utf-8'}
                {elseif $rs.c_state==1}
                <a onclick="member_stop(this,'{$rs.cid}')" href="javascript:;"  title="通过">
                    <span style="color: mediumblue">充值</span>
                </a> ||
                <a title="详情" href="javascript:;" attr_id='{$rs.cid}' onclick="banner_edit(this)">
                    <span style="color: mediumblue">拒绝</span>
                </a>
                {else/}
                <span class="layui-btn layui-btn-sm">充值完成</span>
                {/if}
                </span>
            </td>{else/}{/if}
        </tr>
        {/volist}
        </tbody>
    </table>
    <div class="page">
        <div>
        {$page}
        </div>
    </div>

</div>
<script>
    function banner_edit(obj){
        var mid=$(obj).attr('attr_id');
        //alert(mid);
        var url="{:Url('admin/user/chongzhireason')}?cid="+  mid;
        // alert(url);
        x_admin_show('详情',url);
    }
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });

    /*用户-停用*/
    function member_stop(obj,id){
        layer.confirm('确定充值信用额度到账吗？',function(index){
            $.ajax({
                url:'{:URL("admin/user/chongzhi")}',
                data:{'cid':id},
                type:'post',
                dataType:'json',
                success:function(msg){
                    if(msg==1){
                       //$(obj).parents("tr").find(".td-status").html('');
                       // $(obj).parents("tr").find(".td-manage").html('');
                        $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn layui-btn-sm').html('充值完成');
                        //alert(525);
                        $(obj).parents("tr").find(".td-manage").find('span').addClass('layui-btn layui-btn-sm').html('充值完成');
                        layer.msg('充值成功!',{icon: 1,time:1000});
                    }
                }
            });
            /*if($(obj).attr('title')=='启用'){

                //发异步把用户状态进行更改
                $(obj).attr('title','停用')
                $(obj).find('i').html('&#xe62f;');

                $(obj).parents("tr").find(".td-manage").find('span').addClass('layui-btn-disabled').html('已停用');
                layer.msg('操作成功!',{icon: 5,time:1000});

            }else{
                $(obj).attr('title','启用')
                $(obj).find('i').html('&#xe601;');

                $(obj).parents("tr").find(".td-manage").find('span').removeClass('layui-btn-disabled').html('已启用');
                layer.msg('操作成功!',{icon: 5,time:1000});
            }*/

        });
    }

    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }



    function delAll (argument) {

        var data = tableCheck.getData();

        layer.confirm('确认要删除吗？'+data,function(index){
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
            $(".layui-form-checked").not('.header').parents('tr').remove();
        });
    }
</script>

</body>

</html>